<?php

/**
 * Download filter form base class.
 *
 * @package    xgenpress
 * @subpackage filter
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 29570 2010-05-21 14:49:47Z Kris.Wallsmith $
 */
abstract class BaseDownloadFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'name'          => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'download_type' => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'product_id'    => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Product'), 'add_empty' => true)),
      'press_id'      => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Press'), 'add_empty' => true)),
      'download_link' => new sfWidgetFormFilterInput(array('with_empty' => false)),
    ));

    $this->setValidators(array(
      'name'          => new sfValidatorPass(array('required' => false)),
      'download_type' => new sfValidatorPass(array('required' => false)),
      'product_id'    => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Product'), 'column' => 'id')),
      'press_id'      => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Press'), 'column' => 'id')),
      'download_link' => new sfValidatorPass(array('required' => false)),
    ));

    $this->widgetSchema->setNameFormat('download_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Download';
  }

  public function getFields()
  {
    return array(
      'id'            => 'Number',
      'name'          => 'Text',
      'download_type' => 'Text',
      'product_id'    => 'ForeignKey',
      'press_id'      => 'ForeignKey',
      'download_link' => 'Text',
    );
  }
}
